package com.softer.wxzj.service.impl;

import com.github.pagehelper.PageInfo;
import com.softer.wxzj.common.entity.CommonResult;
import com.softer.wxzj.common.entity.Page;
import com.softer.wxzj.common.util.UUIDUtil;
import com.softer.wxzj.entity.RecoverResidual;
import com.softer.wxzj.mapper.RecoverResidualMapper;
import com.softer.wxzj.service.RecoverResidualService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@Service
public class RecoverResidualServiceImpl implements RecoverResidualService {
    @Autowired
    private RecoverResidualMapper recoverResidualMapper;


    @Override
    public PageInfo<RecoverResidual> selectByPrimaryKey(Page page, String id) {
        List<RecoverResidual> list = recoverResidualMapper.selectByPrimaryKey(id);
        PageInfo<RecoverResidual> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public CommonResult insertSelective(RecoverResidual record) {
        String id = UUIDUtil.getUUID();
        record.setId(id);
        record.setCreateTime(new Date());

        //分摊户数和面积 取自哪个表待定 ---先写固定值
        record.setDivideSum(1);
        record.setDivideArea(new BigDecimal("89"));

        return CommonResult.ResponseResult(recoverResidualMapper.insertSelective(record));
    }
}
